{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "screen=Image.open(\"../ocrdata/test.png\")\n",
    "\n",
    "# 二值化\n",
    "area=screen.crop((18, 2, 41, 14))\n",
    "imggrab=np.mean(area,-1) #灰度 rgb变单通道\n",
    "img=np.where(imggrab[...,:] < 130, 0, 255) # 二值化 #黑色128\n",
    "\n",
    "plt.imshow(area)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(Image.fromarray(img))\n",
    "#二值化就只能根据形状判断了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 水滴算法 0 - 255 由浅到深，看做是坑\n",
    "\n",
    "# 找坑\n",
    "water_drop=[]\n",
    "\n",
    "#生成一张图\n",
    "# map=np.zeros(imggrab.shape)\n",
    "\n",
    "# 寻找低洼点\n",
    "for i in imggrab:\n",
    "    water_drop"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.7"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "3196968d684371006099b3d55edeef8ed90365227a30deaef86e5d4aa8519be0"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
